package com.example.tqyb;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CityWeatherFragment extends Fragment implements View.OnClickListener {

    TextView tempTv,cityTv,conditionTv,windTv,tempRangeTv,dateTv,clothIndexTv,carIndexTv,coldIndexTv,sportIndexTv,raysIndexTv;
    ImageView dayIv;
    LinearLayout futureLayout;
    //视频url格式跟老师给的不一样，结果未知
    String url1="http://apis.juhe.cn/simpleWeather/query?city=";
    String url2="&key=bd2be0ebfb53dcd11c6d2a9d1be7c50f";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view=inflater.inflate(R.layout.fragment_city_weather, container, false);
        initView(view);
        //通过activity传值获取到当前fragment加载的是那个地方的
        Bundle bundle = getArguments();
        String city=bundle.getString("city");
        String url=url1+city+url2;
        return view;
    }

    private void initView(View view){
        tempTv=view.findViewById(R.id.frag_tv_currenttemp);
        cityTv=view.findViewById(R.id.frag_tv_city);
        conditionTv=view.findViewById(R.id.frag_tv_condition);
        windTv=view.findViewById(R.id.frag_tv_wind);
        tempRangeTv=view.findViewById(R.id.frag_tv_temprange);
        dateTv=view.findViewById(R.id.frag_tv_date);
        clothIndexTv=view.findViewById(R.id.frag_index_tv_dress);
        carIndexTv=view.findViewById(R.id.frag_index_tv_washcar);
        coldIndexTv=view.findViewById(R.id.frag_index_tv_cold);
        sportIndexTv=view.findViewById(R.id.frag_index_tv_sport);
        raysIndexTv=view.findViewById(R.id.frag_index_tv_rays);
        dayIv=view.findViewById(R.id.frag_iv_today);
        futureLayout=view.findViewById(R.id.frag_center_layout);
        //设置点击事件的监听
        clothIndexTv.setOnClickListener(this);
        carIndexTv.setOnClickListener(this);
        coldIndexTv.setOnClickListener(this);
        sportIndexTv.setOnClickListener(this);
        raysIndexTv.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.frag_index_tv_dress:

                break;
            case R.id.frag_index_tv_washcar:

                break;
            case R.id.frag_index_tv_cold:

                break;
            case R.id.frag_index_tv_sport:

                break;
            case R.id.frag_index_tv_rays:

                break;
        }
    }
}